
var partition = function (s) {
  // 判断回文数
  function isHuiwen(s) {
    let left = 0
    let right = s.length - 1
    while (left < right) {
      if (s[left] != s[right]) return false
      left++
      right--
    }
    return true
  }
  let ans = []
  const dt = (start, temp) => {
    if(start==s.length) {
      ans.push(temp)
      return 
    }
    for (var i = start; i < s.length; i++) {
      if (isHuiwen(s.substring(start, i + 1))) {
        temp.push(s.substring(start, i + 1))
        dt(i + 1, [...temp])
        temp.pop()
      }
    }
  }
  dt(0, [])
  return ans
};
let s = 'aab'
console.log(partition(s));
// let ar = [1,2,3]
// let b = [...ar]
// b.push(12312)
// console.log(ar);